﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Drawing;
using BI;

namespace HypothesisTester
{
    
    
    /// <summary>
    ///This is a test class for hlpHttpTest and is intended
    ///to contain all hlpHttpTest Unit Tests
    ///</summary>
    [TestClass()]
    public class hlpHttpTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetContentTypeForFile
        ///</summary>
        [TestMethod()]
        [DeploymentItem("RequestTester.exe")]
        public void GetContentTypeForFileTest()
        {
            hlpHttp_Accessor target = new hlpHttp_Accessor();
            
            string fileName = "test.test";
            string expected = "application/unknown";
            string actual;
            
            actual = target.GetContentTypeForFile(fileName);
            
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for StreamCopyTo
        ///</summary>
        [TestMethod()]
        [DeploymentItem("RequestTester.exe")]
        public void StreamCopyToTest()
        {           
            hlpHttp_Accessor target = new hlpHttp_Accessor();

            Stream src = new MemoryStream();
            Bitmap imgSrc = new Bitmap(HypothesisTester.Resource.testimage);
            imgSrc.Save(src, System.Drawing.Imaging.ImageFormat.Jpeg);
            Stream dst = new MemoryStream();

            src.Position = 0;
            dst.Position = 0;

            target.StreamCopyTo(src, dst);

            hlpAssert.AreEqual(src, dst);
        }

    }
}
